package org.teamh.connection.handler;

import org.teamh.game.Start;
import org.teamh.logic.lobby.Game;

public class GameHandler extends MasterHandler {
	
	public GameHandler(Start start) {
		super(start);
	}
	
	public boolean handleMsg(String line) {
		if (line.startsWith("NO GAME") || line.startsWith("GAME")) {
			if (line.startsWith("GAME")) {
				
				String[] str = line.split(" ");
				String name = str[1].substring(5);
				String map = str[3].substring(8);
				String players = str[4].substring(8);
				String status = str[5].substring(7);
				boolean testgame = str[6].contains("true");
				
				Game game = new Game(name, map, players, status, testgame);
				start.getModel().addGame(game);
				
			}
		return true;
		} else {
			return false;
		}
	}

}
